layui.config({
    base: "/layui/"
}).extend({
    index: 'lib/index'
}).use(['index', 'form', 'jquery', 'table', 'upload', 'laydate'], function () {
    var form = layui.form,
        table = layui.table,
        upload = layui.upload,
        laydate = layui.laydate,
        admin = layui.admin;

    //执行一个laydate实例
    laydate.render({
        elem: '#created_time' //指定元素
    });

    /**
     * 防重复设置
     * @type {boolean}
     */
    var edit_flag = true;

    table.render({
        elem: '#department_result'
        , url: '/assignment/queryData'
        , method: 'post'
        , title: ''
        , height: 500
        , limit: 50							//显示数目
        , limits: [50, 100]
        , cols: [[
            {field: 'id', title: 'id', width: 200, "align": "center", hide: true}
            , {field: 'userName', title: '接收人', width: 200, "align": "center"}
            , {field: 'cameraSn', width: 220, title: '摄像头sn序列号', "align": "center"}
            , {field: 'terminalSn', title: '设备sn序列号', width: 220, "align": "center"}
            , {field: 'type', title: '设备类型', width: 200, "align": "center", templet: function (d) {
                    if (d.type == "WECHAT") {
                        return "微信";
                    } else if (d.type == "ALIPAY") {
                        return "支付宝";
                    } else{
                        return "";
                    }
                }}
            , {field: 'createdTime', title: '创建时间', width: 180, "align": "center"}
        ]]
        , request: {
            pageName: 'pageNo' //页码的参数名称，默认：page
            , limitName: 'pageSize' //每页数据量的参数名，默认：LIMIT
        },
        where: {

        }
        , id: 'department_result'
        , page: true
    });


    //查询按钮事件
    $(".order_btn").click(function () {
        table.reload('department_result', {
            page: {
                curr: 1 //重新从第 1 页开始
            }
            , where: {
                userName: $("#userName").val(),
                createdTime: $("#created_time").val()
            }
        });
    });


});